package com.eventm;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.eventm.dao.IUserDao;
import com.eventm.model.User;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:root-dataSource.xml"})
public class Main {
	@Autowired
	IUserDao userDao;
	
	@Test
	public void test() {
		try {
			System.out.println("Test Hibernate.............");
			
			
			User user = new User();
			user.setUsername("Amaresh");
			user.setPassword("123456");
			
			userDao.saveUser(user);
			System.out.println("User Saved");
			
			
			User fetchedUser = userDao.findById(1);
			System.out.println("User Fetched..." + fetchedUser.getUsername());

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
}
